#region Copyright

/*
* ====================================================================
* Copyright (c) 2007 www.dotsvn.net.  All rights reserved.
*
* This software is licensed as described in the file LICENSE, which
* you should have received as part of this distribution.  
* ====================================================================
*/

#endregion //Copyright

using System;
using System.Collections.Generic;

namespace DotSVN.Common.Util
{
    /// <summary>
    /// The <c>SVNErrorCode</c> class represents possible predefined kinds
    /// of errors with their own identifying information. Each <c>SVNErrorCode</c>
    /// has its common description, belongs to a definite category of errors and
    /// also has its unique error code int value based upon the category.
    /// <para>Error codes (values, common descriptions and categories) are similar
    /// to ones in the native SVN.</para>
    /// </summary>
    [Serializable]
    public class SVNErrorCode
    {
        private readonly String description;
        private readonly int category;
        private readonly int code;
        private static readonly Dictionary<int, SVNErrorCode> errorCodes = new Dictionary<int, SVNErrorCode>();

        /// <summary>
        /// Returns a unique error code value.
        /// </summary>
        /// <value>The code.</value>
        public virtual int Code
        {
            get { return code; }
        }

        /// <summary>
        /// Returns the category this error code object belongs to.
        /// </summary>
        /// <value>The category.</value>
        /// <returns>An error code category</returns>
        public virtual int Category
        {
            get { return category; }
        }

        /// <summary>
        /// Returns a description of this error.
        /// </summary>
        /// <value>The description.</value>
        /// <returns>An error description common for all errors of the same error code</returns>
        public virtual String Description
        {
            get { return description; }
        }

        /// <summary>
        /// Returns true if this error is an authentication error.
        /// </summary>
        /// <value><c>true</c> if this is an authentication error; otherwise, <c>false</c>.</value>
        public virtual bool Authentication
        {
            get
            {
                return
                    this == RA_NOT_AUTHORIZED || this == RA_UNKNOWN_AUTH || Category == AUTHZ_CATEGORY ||
                    Category == AUTHN_CATEGORY;
            }
        }

        /// <summary>
        /// Default constructor
        /// </summary>
        public SVNErrorCode()
        {
        }

        /// <summary>
        /// Gets an error code object given its unique error code number.
        /// </summary>
        /// <param name="category">The error category</param>
        /// <param name="index">Index in the category</param>
        /// <param name="description">Error Description</param>
        protected internal SVNErrorCode(int category, int index, String description)
        {
            this.category = category;
            code = category + index;
            this.description = description;
            errorCodes[code] = this;
        }

        /// <summary>
        /// Gets an error code object given its unique error code number.
        /// If no definite error code objects corresponds to the provided value, returns UNKNOWN.
        /// </summary>
        /// <param name="code">an error code number</param>
        /// <returns>Corresponding <c>SVNErrorCode</c>.</returns>
        public static SVNErrorCode GetErrorCode(int code)
        {
            SVNErrorCode errorCode = errorCodes[code];
            if (errorCode == null)
            {
                errorCode = UNKNOWN;
            }
            return errorCode;
        }

        /// <summary>
        /// Returns a hash for this object
        /// </summary>
        /// <returns>
        /// A hash code for the current <see cref="T:System.Object"></see>.
        /// </returns>
        public override int GetHashCode()
        {
            return code;
        }

        /// <summary>
        /// Determines whether the specified Object is equal to the current Object
        /// </summary>
        /// <param name="o">The Object to compare with the current Object</param>
        /// <returns>
        /// true if the specified Object is equal to the current Object; otherwise, false.
        /// </returns>
        public override bool Equals(Object o)
        {
            if (o == null || o.GetType() != typeof (SVNErrorCode))
            {
                return false;
            }
            return code == ((SVNErrorCode) o).code;
        }

        /// <summary>
        /// Returns a String that represents the current Object.
        /// </summary>
        /// <returns>
        /// A String that represents the current Object.
        /// </returns>
        public override String ToString()
        {
            return code + ": " + description;
        }


        private const int ERR_BASE = 120000;
        private const int ERR_CATEGORY_SIZE = 5000;

        #region Error Categorys

#pragma warning disable 1591
        public static readonly int BAD_CATEGORY = ERR_BASE + 1*ERR_CATEGORY_SIZE;
        public static readonly int XML_CATEGORY = ERR_BASE + 2*ERR_CATEGORY_SIZE;
        public static readonly int IO_CATEGORY = ERR_BASE + 3*ERR_CATEGORY_SIZE;
        public static readonly int STREAM_CATEGORY = ERR_BASE + 4*ERR_CATEGORY_SIZE;
        public static readonly int NODE_CATEGORY = ERR_BASE + 5*ERR_CATEGORY_SIZE;
        public static readonly int ENTRY_CATEGORY = ERR_BASE + 6*ERR_CATEGORY_SIZE;
        public static readonly int WC_CATEGORY = ERR_BASE + 7*ERR_CATEGORY_SIZE;
        public static readonly int FS_CATEGORY = ERR_BASE + 8*ERR_CATEGORY_SIZE;
        public static readonly int REPOS_CATEGORY = ERR_BASE + 9*ERR_CATEGORY_SIZE;
        public static readonly int RA_CATEGORY = ERR_BASE + 10*ERR_CATEGORY_SIZE;
        public static readonly int RA_DAV_CATEGORY = ERR_BASE + 11*ERR_CATEGORY_SIZE;
        public static readonly int RA_LOCAL_CATEGORY = ERR_BASE + 12*ERR_CATEGORY_SIZE;
        public static readonly int SVNDIFF_CATEGORY = ERR_BASE + 13*ERR_CATEGORY_SIZE;
        public static readonly int APMOD_CATEGORY = ERR_BASE + 14*ERR_CATEGORY_SIZE;
        public static readonly int CLIENT_CATEGORY = ERR_BASE + 15*ERR_CATEGORY_SIZE;
        public static readonly int MISC_CATEGORY = ERR_BASE + 16*ERR_CATEGORY_SIZE;
        public static readonly int CL_CATEGORY = ERR_BASE + 17*ERR_CATEGORY_SIZE;
        public static readonly int RA_SVN_CATEGORY = ERR_BASE + 18*ERR_CATEGORY_SIZE;
        public static readonly int AUTHN_CATEGORY = ERR_BASE + 19*ERR_CATEGORY_SIZE;
        public static readonly int AUTHZ_CATEGORY = ERR_BASE + 20*ERR_CATEGORY_SIZE;

        #endregion

        public static readonly SVNErrorCode UNKNOWN =
            new SVNErrorCode(MISC_CATEGORY, ERR_CATEGORY_SIZE - 100, "Unknown error");

        public static readonly SVNErrorCode IO_ERROR =
            new SVNErrorCode(MISC_CATEGORY, ERR_CATEGORY_SIZE - 101, "Generic IO error");

        public static readonly SVNErrorCode BAD_CONTAINING_POOL =
            new SVNErrorCode(BAD_CATEGORY, 0, "Bad parent pool passed to svn_make_pool()");

        public static readonly SVNErrorCode BAD_FILENAME = new SVNErrorCode(BAD_CATEGORY, 1, "Bogus filename");
        public static readonly SVNErrorCode BAD_URL = new SVNErrorCode(BAD_CATEGORY, 2, "Bogus URL");
        public static readonly SVNErrorCode BAD_DATE = new SVNErrorCode(BAD_CATEGORY, 3, "Bogus date");
        public static readonly SVNErrorCode BAD_MIME_TYPE = new SVNErrorCode(BAD_CATEGORY, 4, "Bogus mime-type");

        public static readonly SVNErrorCode BAD_VERSION_FILE_FORMAT =
            new SVNErrorCode(BAD_CATEGORY, 6, "Version file format not correct");

        public static readonly SVNErrorCode XML_ATTRIB_NOT_FOUND =
            new SVNErrorCode(XML_CATEGORY, 0, "No such XML tag attribute");

        public static readonly SVNErrorCode XML_MISSING_ANCESTRY =
            new SVNErrorCode(XML_CATEGORY, 1, "<delta-pkg> is missing ancestry");

        public static readonly SVNErrorCode XML_UNKNOWN_ENCODING =
            new SVNErrorCode(XML_CATEGORY, 2, "Unrecognized binary data encoding; can't decode");

        public static readonly SVNErrorCode XML_MALFORMED =
            new SVNErrorCode(XML_CATEGORY, 3, "XML data was not well-formed");

        public static readonly SVNErrorCode XML_UNESCAPABLE_DATA =
            new SVNErrorCode(XML_CATEGORY, 4, "Data cannot be safely XML-escaped");

        public static readonly SVNErrorCode IO_INCONSISTENT_EOL =
            new SVNErrorCode(IO_CATEGORY, 0, "Inconsistent line ending style");

        public static readonly SVNErrorCode IO_UNKNOWN_EOL =
            new SVNErrorCode(IO_CATEGORY, 1, "Unrecognized line ending style");

        public static readonly SVNErrorCode IO_CORRUPT_EOL =
            new SVNErrorCode(IO_CATEGORY, 2, "Line endings other than expected");

        public static readonly SVNErrorCode IO_UNIQUE_NAMES_EXHAUSTED =
            new SVNErrorCode(IO_CATEGORY, 3, "Ran out of unique names");

        public static readonly SVNErrorCode IO_PIPE_FRAME_ERROR =
            new SVNErrorCode(IO_CATEGORY, 4, "Framing error in pipe protocol");

        public static readonly SVNErrorCode IO_PIPE_READ_ERROR = new SVNErrorCode(IO_CATEGORY, 5, "Read error in pipe");
        public static readonly SVNErrorCode IO_WRITE_ERROR = new SVNErrorCode(IO_CATEGORY, 6, "Write error");

        public static readonly SVNErrorCode STREAM_UNEXPECTED_EOF =
            new SVNErrorCode(STREAM_CATEGORY, 0, "Unexpected EOF on stream");

        public static readonly SVNErrorCode STREAM_MALFORMED_DATA =
            new SVNErrorCode(STREAM_CATEGORY, 1, "Malformed stream data");

        public static readonly SVNErrorCode STREAM_UNRECOGNIZED_DATA =
            new SVNErrorCode(STREAM_CATEGORY, 2, "Unrecognized stream data");

        public static readonly SVNErrorCode NODE_UNKNOWN_KIND =
            new SVNErrorCode(NODE_CATEGORY, 0, "Unknown svn_node_kind");

        public static readonly SVNErrorCode NODE_UNEXPECTED_KIND =
            new SVNErrorCode(NODE_CATEGORY, 1, "Unexpected node kind found");

        public static readonly SVNErrorCode ENTRY_NOT_FOUND = new SVNErrorCode(ENTRY_CATEGORY, 0, "Can't find an entry");
        public static readonly SVNErrorCode ENTRY_EXISTS = new SVNErrorCode(ENTRY_CATEGORY, 2, "Entry already exists");

        public static readonly SVNErrorCode ENTRY_MISSING_REVISION =
            new SVNErrorCode(ENTRY_CATEGORY, 3, "Entry has no revision");

        public static readonly SVNErrorCode ENTRY_MISSING_URL = new SVNErrorCode(ENTRY_CATEGORY, 4, "Entry has no URL");

        public static readonly SVNErrorCode ENTRY_ATTRIBUTE_INVALID =
            new SVNErrorCode(ENTRY_CATEGORY, 5, "Entry has an invalid attribute");

        public static readonly SVNErrorCode WC_OBSTRUCTED_UPDATE = new SVNErrorCode(WC_CATEGORY, 0, "Obstructed update");

        public static readonly SVNErrorCode WC_UNWIND_MISMATCH =
            new SVNErrorCode(WC_CATEGORY, 1, "Mismatch popping the WC unwind stack");

        public static readonly SVNErrorCode WC_UNWIND_EMPTY =
            new SVNErrorCode(WC_CATEGORY, 2, "Attempt to pop empty WC unwind stack");

        public static readonly SVNErrorCode WC_UNWIND_NOT_EMPTY =
            new SVNErrorCode(WC_CATEGORY, 3, "Attempt to unlock with non-empty unwind stack");

        public static readonly SVNErrorCode WC_LOCKED =
            new SVNErrorCode(WC_CATEGORY, 4, "Attempted to lock an already-locked dir");

        public static readonly SVNErrorCode WC_NOT_LOCKED =
            new SVNErrorCode(WC_CATEGORY, 5, "Working copy not locked; this is probably a bug, please report");

        public static readonly SVNErrorCode WC_INVALID_LOCK = new SVNErrorCode(WC_CATEGORY, 6, "Invalid lock");

        public static readonly SVNErrorCode WC_NOT_DIRECTORY =
            new SVNErrorCode(WC_CATEGORY, 7, "Path is not a working copy directory");

        public static readonly SVNErrorCode WC_NOT_FILE =
            new SVNErrorCode(WC_CATEGORY, 8, "Path is not a working copy file");

        public static readonly SVNErrorCode WC_BAD_ADM_LOG = new SVNErrorCode(WC_CATEGORY, 9, "Problem running log");

        public static readonly SVNErrorCode WC_PATH_NOT_FOUND =
            new SVNErrorCode(WC_CATEGORY, 10, "Can't find a working copy path");

        public static readonly SVNErrorCode WC_NOT_UP_TO_DATE =
            new SVNErrorCode(WC_CATEGORY, 11, "Working copy is not up-to-date");

        public static readonly SVNErrorCode WC_LEFT_LOCAL_MOD =
            new SVNErrorCode(WC_CATEGORY, 12, "Left locally modified or unversioned files");

        public static readonly SVNErrorCode WC_SCHEDULE_CONFLICT =
            new SVNErrorCode(WC_CATEGORY, 13, "Unmergeable scheduling requested on an entry");

        public static readonly SVNErrorCode WC_PATH_FOUND =
            new SVNErrorCode(WC_CATEGORY, 14, "Found a working copy path");

        public static readonly SVNErrorCode WC_FOUND_CONFLICT =
            new SVNErrorCode(WC_CATEGORY, 15, "A conflict in the working copy obstructs the current operation");

        public static readonly SVNErrorCode WC_CORRUPT = new SVNErrorCode(WC_CATEGORY, 16, "Working copy is corrupt");

        public static readonly SVNErrorCode WC_CORRUPT_TEXT_BASE =
            new SVNErrorCode(WC_CATEGORY, 17, "Working copy text base is corrupt");

        public static readonly SVNErrorCode WC_NODE_KIND_CHANGE =
            new SVNErrorCode(WC_CATEGORY, 18, "Cannot change node kind");

        public static readonly SVNErrorCode WC_INVALID_OP_ON_CWD =
            new SVNErrorCode(WC_CATEGORY, 19, "Invalid operation on the current working directory");

        public static readonly SVNErrorCode WC_BAD_ADM_LOG_START =
            new SVNErrorCode(WC_CATEGORY, 20, "Problem on first log entry in a working copy");

        public static readonly SVNErrorCode WC_UNSUPPORTED_FORMAT =
            new SVNErrorCode(WC_CATEGORY, 21, "Unsupported working copy format");

        public static readonly SVNErrorCode WC_BAD_PATH =
            new SVNErrorCode(WC_CATEGORY, 22, "Path syntax not supported in this context");

        public static readonly SVNErrorCode WC_INVALID_SCHEDULE = new SVNErrorCode(WC_CATEGORY, 23, "Invalid schedule");

        public static readonly SVNErrorCode WC_INVALID_RELOCATION =
            new SVNErrorCode(WC_CATEGORY, 24, "Invalid relocation");

        public static readonly SVNErrorCode WC_INVALID_SWITCH = new SVNErrorCode(WC_CATEGORY, 25, "Invalid switch");

        public static readonly SVNErrorCode FS_GENERAL = new SVNErrorCode(FS_CATEGORY, 0, "General filesystem error");
        public static readonly SVNErrorCode FS_CLEANUP = new SVNErrorCode(FS_CATEGORY, 1, "Error closing filesystem");

        public static readonly SVNErrorCode FS_ALREADY_OPEN =
            new SVNErrorCode(FS_CATEGORY, 2, "Filesystem is already open");

        public static readonly SVNErrorCode FS_NOT_OPEN = new SVNErrorCode(FS_CATEGORY, 3, "Filesystem is not open");
        public static readonly SVNErrorCode FS_CORRUPT = new SVNErrorCode(FS_CATEGORY, 4, "Filesystem is corrupt");

        public static readonly SVNErrorCode FS_PATH_SYNTAX =
            new SVNErrorCode(FS_CATEGORY, 5, "Invalid filesystem path syntax");

        public static readonly SVNErrorCode FS_NO_SUCH_REVISION =
            new SVNErrorCode(FS_CATEGORY, 6, "Invalid filesystem revision number");

        public static readonly SVNErrorCode FS_NO_SUCH_TRANSACTION =
            new SVNErrorCode(FS_CATEGORY, 7, "Invalid filesystem transaction name");

        public static readonly SVNErrorCode FS_NO_SUCH_ENTRY =
            new SVNErrorCode(FS_CATEGORY, 8, "Filesystem directory has no such entry");

        public static readonly SVNErrorCode FS_NO_SUCH_REPRESENTATION =
            new SVNErrorCode(FS_CATEGORY, 9, "Filesystem has no such representation");

        public static readonly SVNErrorCode FS_NO_SUCH_STRING =
            new SVNErrorCode(FS_CATEGORY, 10, "Filesystem has no such string");

        public static readonly SVNErrorCode FS_NO_SUCH_COPY =
            new SVNErrorCode(FS_CATEGORY, 11, "Filesystem has no such copy");

        public static readonly SVNErrorCode FS_TRANSACTION_NOT_MUTABLE =
            new SVNErrorCode(FS_CATEGORY, 12, "The specified transaction is not mutable");

        public static readonly SVNErrorCode FS_NOT_FOUND = new SVNErrorCode(FS_CATEGORY, 13, "Filesystem has no item");

        public static readonly SVNErrorCode FS_ID_NOT_FOUND =
            new SVNErrorCode(FS_CATEGORY, 14, "Filesystem has no such node-rev-id");

        public static readonly SVNErrorCode FS_NOT_ID =
            new SVNErrorCode(FS_CATEGORY, 15, "String does not represent a node or node-rev-id");

        public static readonly SVNErrorCode FS_NOT_DIRECTORY =
            new SVNErrorCode(FS_CATEGORY, 16, "Name does not refer to a filesystem directory");

        public static readonly SVNErrorCode FS_NOT_FILE =
            new SVNErrorCode(FS_CATEGORY, 17, "Name does not refer to a filesystem file");

        public static readonly SVNErrorCode FS_NOT_SINGLE_PATH_COMPONENT =
            new SVNErrorCode(FS_CATEGORY, 18, "Name is not a single path component");

        public static readonly SVNErrorCode FS_NOT_MUTABLE =
            new SVNErrorCode(FS_CATEGORY, 19, "Attempt to change immutable filesystem node");

        public static readonly SVNErrorCode FS_ALREADY_EXISTS =
            new SVNErrorCode(FS_CATEGORY, 20, "Item already exists in filesystem");

        public static readonly SVNErrorCode FS_ROOT_DIR =
            new SVNErrorCode(FS_CATEGORY, 21, "Attempt to remove or recreate fs root dir");

        public static readonly SVNErrorCode FS_NOT_TXN_ROOT =
            new SVNErrorCode(FS_CATEGORY, 22, "Object is not a transaction root");

        public static readonly SVNErrorCode FS_NOT_REVISION_ROOT =
            new SVNErrorCode(FS_CATEGORY, 23, "Object is not a revision root");

        public static readonly SVNErrorCode FS_CONFLICT =
            new SVNErrorCode(FS_CATEGORY, 24, "Merge conflict during commit");

        public static readonly SVNErrorCode FS_REP_CHANGED =
            new SVNErrorCode(FS_CATEGORY, 25, "A representation vanished or changed between reads");

        public static readonly SVNErrorCode FS_REP_NOT_MUTABLE =
            new SVNErrorCode(FS_CATEGORY, 26, "Tried to change an immutable representation");

        public static readonly SVNErrorCode FS_MALFORMED_SKEL =
            new SVNErrorCode(FS_CATEGORY, 27, "Malformed skeleton data");

        public static readonly SVNErrorCode FS_TXN_OUT_OF_DATE =
            new SVNErrorCode(FS_CATEGORY, 28, "Transaction is out of date");

        public static readonly SVNErrorCode FS_BERKELEY_DB = new SVNErrorCode(FS_CATEGORY, 29, "Berkeley DB error");

        public static readonly SVNErrorCode FS_BERKELEY_DB_DEADLOCK =
            new SVNErrorCode(FS_CATEGORY, 30, "Berkeley DB deadlock error");

        public static readonly SVNErrorCode FS_TRANSACTION_DEAD =
            new SVNErrorCode(FS_CATEGORY, 31, "Transaction is dead");

        public static readonly SVNErrorCode FS_TRANSACTION_NOT_DEAD =
            new SVNErrorCode(FS_CATEGORY, 32, "Transaction is not dead");

        public static readonly SVNErrorCode FS_UNKNOWN_FS_TYPE = new SVNErrorCode(FS_CATEGORY, 33, "Unknown FS type");

        public static readonly SVNErrorCode FS_NO_USER =
            new SVNErrorCode(FS_CATEGORY, 34, "No user associated with filesystem");

        public static readonly SVNErrorCode FS_PATH_ALREADY_LOCKED =
            new SVNErrorCode(FS_CATEGORY, 35, "Path is already locked");

        public static readonly SVNErrorCode FS_PATH_NOT_LOCKED = new SVNErrorCode(FS_CATEGORY, 36, "Path is not locked");

        public static readonly SVNErrorCode FS_BAD_LOCK_TOKEN =
            new SVNErrorCode(FS_CATEGORY, 37, "Lock token is incorrect");

        public static readonly SVNErrorCode FS_NO_LOCK_TOKEN =
            new SVNErrorCode(FS_CATEGORY, 38, "No lock token provided");

        public static readonly SVNErrorCode FS_LOCK_OWNER_MISMATCH =
            new SVNErrorCode(FS_CATEGORY, 39, "Username does not match lock owner");

        public static readonly SVNErrorCode FS_NO_SUCH_LOCK =
            new SVNErrorCode(FS_CATEGORY, 40, "Filesystem has no such lock");

        public static readonly SVNErrorCode FS_LOCK_EXPIRED = new SVNErrorCode(FS_CATEGORY, 41, "Lock has expired");
        public static readonly SVNErrorCode FS_OUT_OF_DATE = new SVNErrorCode(FS_CATEGORY, 42, "Item is out of date");

        public static readonly SVNErrorCode FS_UNSUPPORTED_FORMAT =
            new SVNErrorCode(FS_CATEGORY, 43, "Unsupported FS format");

        public static readonly SVNErrorCode REPOS_LOCKED =
            new SVNErrorCode(REPOS_CATEGORY, 0, "The repository is locked, perhaps for db recovery");

        public static readonly SVNErrorCode REPOS_HOOK_FAILURE =
            new SVNErrorCode(REPOS_CATEGORY, 1, "A repository hook failed");

        public static readonly SVNErrorCode REPOS_BAD_ARGS =
            new SVNErrorCode(REPOS_CATEGORY, 2, "Incorrect arguments supplied");

        public static readonly SVNErrorCode REPOS_NO_DATA_FOR_REPORT =
            new SVNErrorCode(REPOS_CATEGORY, 3, "A report cannot be generated because no data was supplied");

        public static readonly SVNErrorCode REPOS_BAD_REVISION_REPORT =
            new SVNErrorCode(REPOS_CATEGORY, 4, "Bogus revision report");

        public static readonly SVNErrorCode REPOS_UNSUPPORTED_VERSION =
            new SVNErrorCode(REPOS_CATEGORY, 5, "Unsupported repository version");

        public static readonly SVNErrorCode REPOS_DISABLED_FEATURE =
            new SVNErrorCode(REPOS_CATEGORY, 6, "Disabled repository feature");

        public static readonly SVNErrorCode REPOS_POST_COMMIT_HOOK_FAILED =
            new SVNErrorCode(REPOS_CATEGORY, 7, "Error running post-commit hook");

        public static readonly SVNErrorCode REPOS_POST_LOCK_HOOK_FAILED =
            new SVNErrorCode(REPOS_CATEGORY, 8, "Error running post-lock hook");

        public static readonly SVNErrorCode REPOS_POST_UNLOCK_HOOK_FAILED =
            new SVNErrorCode(REPOS_CATEGORY, 9, "Error running post-unlock hook");

        public static readonly SVNErrorCode RA_ILLEGAL_URL =
            new SVNErrorCode(RA_CATEGORY, 0, "Bad URL passed to RA layer");

        public static readonly SVNErrorCode RA_NOT_AUTHORIZED = new SVNErrorCode(RA_CATEGORY, 1, "Authorization failed");

        public static readonly SVNErrorCode RA_UNKNOWN_AUTH =
            new SVNErrorCode(RA_CATEGORY, 2, "Unknown authorization method");

        public static readonly SVNErrorCode RA_NOT_IMPLEMENTED =
            new SVNErrorCode(RA_CATEGORY, 3, "Repository access method not implemented");

        public static readonly SVNErrorCode RA_OUT_OF_DATE = new SVNErrorCode(RA_CATEGORY, 4, "Item is out-of-date");

        public static readonly SVNErrorCode RA_NO_REPOS_UUID =
            new SVNErrorCode(RA_CATEGORY, 5, "Repository has no UUID");

        public static readonly SVNErrorCode RA_UNSUPPORTED_ABI_VERSION =
            new SVNErrorCode(RA_CATEGORY, 6, "Unsupported RA plugin ABI version");

        public static readonly SVNErrorCode RA_NOT_LOCKED = new SVNErrorCode(RA_CATEGORY, 7, "Path is not locked");

        public static readonly SVNErrorCode RA_DAV_SOCK_INIT =
            new SVNErrorCode(RA_DAV_CATEGORY, 0, "RA layer failed to init socket layer");

        public static readonly SVNErrorCode RA_DAV_CREATING_REQUEST =
            new SVNErrorCode(RA_DAV_CATEGORY, 1, "RA layer failed to Create HTTP request");

        public static readonly SVNErrorCode RA_DAV_REQUEST_FAILED =
            new SVNErrorCode(RA_DAV_CATEGORY, 2, "RA layer request failed");

        public static readonly SVNErrorCode RA_DAV_OPTIONS_REQ_FAILED =
            new SVNErrorCode(RA_DAV_CATEGORY, 3, "RA layer didn't receive requested OPTIONS info");

        public static readonly SVNErrorCode RA_DAV_PROPS_NOT_FOUND =
            new SVNErrorCode(RA_DAV_CATEGORY, 4, "RA layer failed to fetch properties");

        public static readonly SVNErrorCode RA_DAV_ALREADY_EXISTS =
            new SVNErrorCode(RA_DAV_CATEGORY, 5, "RA layer file already exists");

        public static readonly SVNErrorCode RA_DAV_INVALID_CONFIG_VALUE =
            new SVNErrorCode(RA_DAV_CATEGORY, 6, "Invalid configuration value");

        public static readonly SVNErrorCode RA_DAV_PATH_NOT_FOUND =
            new SVNErrorCode(RA_DAV_CATEGORY, 7, "HTTP Path Not Found");

        public static readonly SVNErrorCode RA_DAV_PROPPATCH_FAILED =
            new SVNErrorCode(RA_DAV_CATEGORY, 8, "Failed to execute WebDAV PROPPATCH");

        public static readonly SVNErrorCode RA_DAV_MALFORMED_DATA =
            new SVNErrorCode(RA_DAV_CATEGORY, 9, "Malformed network data");

        public static readonly SVNErrorCode RA_DAV_RESPONSE_HEADER_BADNESS =
            new SVNErrorCode(RA_DAV_CATEGORY, 10, "Unable to extract data from response header");

        public static readonly SVNErrorCode RA_LOCAL_REPOS_NOT_FOUND =
            new SVNErrorCode(RA_LOCAL_CATEGORY, 0, "Couldn't find a repository");

        public static readonly SVNErrorCode RA_LOCAL_REPOS_OPEN_FAILED =
            new SVNErrorCode(RA_LOCAL_CATEGORY, 1, "Couldn't open a repository");

        public static readonly SVNErrorCode RA_SVN_CMD_ERR =
            new SVNErrorCode(RA_SVN_CATEGORY, 0, "Special code for wrapping server errors to report to client");

        public static readonly SVNErrorCode RA_SVN_UNKNOWN_CMD =
            new SVNErrorCode(RA_SVN_CATEGORY, 1, "Unknown svn protocol command");

        public static readonly SVNErrorCode RA_SVN_CONNECTION_CLOSED =
            new SVNErrorCode(RA_SVN_CATEGORY, 2, "Network connection closed unexpectedly");

        public static readonly SVNErrorCode RA_SVN_IO_ERROR =
            new SVNErrorCode(RA_SVN_CATEGORY, 3, "Network read/write error");

        public static readonly SVNErrorCode RA_SVN_MALFORMED_DATA =
            new SVNErrorCode(RA_SVN_CATEGORY, 4, "Malformed network data");

        public static readonly SVNErrorCode RA_SVN_REPOS_NOT_FOUND =
            new SVNErrorCode(RA_SVN_CATEGORY, 5, "Couldn't find a repository");

        public static readonly SVNErrorCode RA_SVN_BAD_VERSION =
            new SVNErrorCode(RA_SVN_CATEGORY, 6, "Client/server version mismatch");

        public static readonly SVNErrorCode AUTHN_CREDS_UNAVAILABLE =
            new SVNErrorCode(AUTHN_CATEGORY, 0, "Credential data unavailable");

        public static readonly SVNErrorCode AUTHN_NO_PROVIDER =
            new SVNErrorCode(AUTHN_CATEGORY, 1, "No authentication provider available");

        public static readonly SVNErrorCode AUTHN_PROVIDERS_EXHAUSTED =
            new SVNErrorCode(AUTHN_CATEGORY, 2, "All authentication providers exhausted");

        public static readonly SVNErrorCode AUTHN_CREDS_NOT_SAVED =
            new SVNErrorCode(AUTHN_CATEGORY, 3, "All authentication providers exhausted");

        public static readonly SVNErrorCode AUTHZ_ROOT_UNREADABLE =
            new SVNErrorCode(AUTHZ_CATEGORY, 0, "Read access denied for root of edit");

        public static readonly SVNErrorCode AUTHZ_UNREADABLE =
            new SVNErrorCode(AUTHZ_CATEGORY, 1, "Item is not readable");

        public static readonly SVNErrorCode AUTHZ_PARTIALLY_READABLE =
            new SVNErrorCode(AUTHZ_CATEGORY, 2, "Item is partially readable");

        public static readonly SVNErrorCode AUTHZ_INVALID_CONFIG =
            new SVNErrorCode(AUTHZ_CATEGORY, 3, "Invalid authz configuration");

        public static readonly SVNErrorCode AUTHZ_UNWRITABLE =
            new SVNErrorCode(AUTHZ_CATEGORY, 4, "Item is not writable");

        public static readonly SVNErrorCode SVNDIFF_INVALID_HEADER =
            new SVNErrorCode(SVNDIFF_CATEGORY, 0, "Svndiff data has invalid header");

        public static readonly SVNErrorCode SVNDIFF_CORRUPT_WINDOW =
            new SVNErrorCode(SVNDIFF_CATEGORY, 1, "Svndiff data contains corrupt window");

        public static readonly SVNErrorCode SVNDIFF_BACKWARD_VIEW =
            new SVNErrorCode(SVNDIFF_CATEGORY, 2, "Svndiff data contains backward-sliding source view");

        public static readonly SVNErrorCode SVNDIFF_INVALID_OPS =
            new SVNErrorCode(SVNDIFF_CATEGORY, 3, "Svndiff data contains invalid instruction");

        public static readonly SVNErrorCode SVNDIFF_UNEXPECTED_END =
            new SVNErrorCode(SVNDIFF_CATEGORY, 4, "Svndiff data ends unexpectedly");

        public static readonly SVNErrorCode APMOD_MISSING_PATH_TO_FS =
            new SVNErrorCode(APMOD_CATEGORY, 0, "Apache has no path to an SVN filesystem");

        public static readonly SVNErrorCode APMOD_MALFORMED_URI =
            new SVNErrorCode(APMOD_CATEGORY, 1, "Apache got a malformed URI");

        public static readonly SVNErrorCode APMOD_ACTIVITY_NOT_FOUND =
            new SVNErrorCode(APMOD_CATEGORY, 2, "Activity not found");

        public static readonly SVNErrorCode APMOD_BAD_BASELINE =
            new SVNErrorCode(APMOD_CATEGORY, 3, "Baseline incorrect");

        public static readonly SVNErrorCode APMOD_CONNECTION_ABORTED =
            new SVNErrorCode(APMOD_CATEGORY, 4, "Input/output error");

        public static readonly SVNErrorCode CLIENT_VERSIONED_PATH_REQUIRED =
            new SVNErrorCode(CLIENT_CATEGORY, 0, "A path under version control is needed for this operation");

        public static readonly SVNErrorCode CLIENT_RA_ACCESS_REQUIRED =
            new SVNErrorCode(CLIENT_CATEGORY, 1, "Repository access is needed for this operation");

        public static readonly SVNErrorCode CLIENT_BAD_REVISION =
            new SVNErrorCode(CLIENT_CATEGORY, 2, "Bogus revision information given");

        public static readonly SVNErrorCode CLIENT_DUPLICATE_COMMIT_URL =
            new SVNErrorCode(CLIENT_CATEGORY, 3, "Attempting to commit to a URL more than once");

        public static readonly SVNErrorCode CLIENT_IS_BINARY_FILE =
            new SVNErrorCode(CLIENT_CATEGORY, 4, "Operation does not apply to binary file");

        public static readonly SVNErrorCode CLIENT_INVALID_EXTERNALS_DESCRIPTION =
            new SVNErrorCode(CLIENT_CATEGORY, 5, "Format of an svn:externals property was invalid");

        public static readonly SVNErrorCode CLIENT_MODIFIED =
            new SVNErrorCode(CLIENT_CATEGORY, 6, "Attempting restricted operation for modified resource");

        public static readonly SVNErrorCode CLIENT_IS_DIRECTORY =
            new SVNErrorCode(CLIENT_CATEGORY, 7, "Operation does not apply to directory");

        public static readonly SVNErrorCode CLIENT_REVISION_RANGE =
            new SVNErrorCode(CLIENT_CATEGORY, 8, "Revision range is not allowed");

        public static readonly SVNErrorCode CLIENT_INVALID_RELOCATION =
            new SVNErrorCode(CLIENT_CATEGORY, 9, "Inter-repository relocation not allowed");

        public static readonly SVNErrorCode CLIENT_REVISION_AUTHOR_CONTAINS_NEWLINE =
            new SVNErrorCode(CLIENT_CATEGORY, 10, "Author name cannot contain a newline");

        public static readonly SVNErrorCode CLIENT_PROPERTY_NAME =
            new SVNErrorCode(CLIENT_CATEGORY, 11, "Bad property name");

        public static readonly SVNErrorCode CLIENT_UNRELATED_RESOURCES =
            new SVNErrorCode(CLIENT_CATEGORY, 12, "Two versioned resources are unrelated");

        public static readonly SVNErrorCode CLIENT_MISSING_LOCK_TOKEN =
            new SVNErrorCode(CLIENT_CATEGORY, 13, "Path has no lock token");

        public static readonly SVNErrorCode BASE =
            new SVNErrorCode(MISC_CATEGORY, 0, "A problem occurred; see later errors for details");

        public static readonly SVNErrorCode PLUGIN_LOAD_FAILURE =
            new SVNErrorCode(MISC_CATEGORY, 1, "Failure loading plugin");

        public static readonly SVNErrorCode MALFORMED_FILE = new SVNErrorCode(MISC_CATEGORY, 2, "Malformed file");
        public static readonly SVNErrorCode INCOMPLETE_DATA = new SVNErrorCode(MISC_CATEGORY, 3, "Incomplete data");

        public static readonly SVNErrorCode INCORRECT_PARAMS =
            new SVNErrorCode(MISC_CATEGORY, 4, "Incorrect parameters given");

        public static readonly SVNErrorCode UNVERSIONED_RESOURCE =
            new SVNErrorCode(MISC_CATEGORY, 5, "Tried a versioning operation on an unversioned resource");

        public static readonly SVNErrorCode TEST_FAILED = new SVNErrorCode(MISC_CATEGORY, 6, "Test failed");

        public static readonly SVNErrorCode UNSUPPORTED_FEATURE =
            new SVNErrorCode(MISC_CATEGORY, 7, "Trying to use an unsupported feature");

        public static readonly SVNErrorCode BAD_PROP_KIND =
            new SVNErrorCode(MISC_CATEGORY, 8, "Unexpected or unknown property kind");

        public static readonly SVNErrorCode ILLEGAL_TARGET =
            new SVNErrorCode(MISC_CATEGORY, 9, "Illegal target for the requested operation");

        public static readonly SVNErrorCode DELTA_MD5_CHECKSUM_ABSENT =
            new SVNErrorCode(MISC_CATEGORY, 10, "MD5 checksum is missing");

        public static readonly SVNErrorCode DIR_NOT_EMPTY =
            new SVNErrorCode(MISC_CATEGORY, 11, "Directory needs to be empty but is not");

        public static readonly SVNErrorCode EXTERNAL_PROGRAM =
            new SVNErrorCode(MISC_CATEGORY, 12, "Error calling external program");

        public static readonly SVNErrorCode SWIG_PY_EXCEPTION_SET =
            new SVNErrorCode(MISC_CATEGORY, 13, "Python exception has been set with the error");

        public static readonly SVNErrorCode CHECKSUM_MISMATCH =
            new SVNErrorCode(MISC_CATEGORY, 14, "A checksum mismatch occurred");

        public static readonly SVNErrorCode CANCELLED =
            new SVNErrorCode(MISC_CATEGORY, 15, "The operation was interrupted");

        public static readonly SVNErrorCode INVALID_DIFF_OPTION =
            new SVNErrorCode(MISC_CATEGORY, 16, "The specified diff option is not supported");

        public static readonly SVNErrorCode PROPERTY_NOT_FOUND =
            new SVNErrorCode(MISC_CATEGORY, 17, "Property not found");

        public static readonly SVNErrorCode NO_AUTH_FILE_PATH =
            new SVNErrorCode(MISC_CATEGORY, 18, "No auth file path available");

        public static readonly SVNErrorCode VERSION_MISMATCH =
            new SVNErrorCode(MISC_CATEGORY, 19, "Incompatible library version");

        public static readonly SVNErrorCode CL_ARG_PARSING_ERROR =
            new SVNErrorCode(CL_CATEGORY, 0, "Client error in parsing arguments");

        public static readonly SVNErrorCode CL_INSUFFICIENT_ARGS =
            new SVNErrorCode(CL_CATEGORY, 1, "Not enough args provided");

        public static readonly SVNErrorCode CL_MUTUALLY_EXCLUSIVE_ARGS =
            new SVNErrorCode(CL_CATEGORY, 2, "Mutually exclusive arguments specified");

        public static readonly SVNErrorCode CL_ADM_DIR_RESERVED =
            new SVNErrorCode(CL_CATEGORY, 3, "Attempted command in administrative dir");

        public static readonly SVNErrorCode CL_LOG_MESSAGE_IS_VERSIONED_FILE =
            new SVNErrorCode(CL_CATEGORY, 4, "The log message file is under version control");

        public static readonly SVNErrorCode CL_LOG_MESSAGE_IS_PATHNAME =
            new SVNErrorCode(CL_CATEGORY, 5, "The log message is a pathname");

        public static readonly SVNErrorCode CL_COMMIT_IN_ADDED_DIR =
            new SVNErrorCode(CL_CATEGORY, 6, "Committing in directory scheduled for addition");

        public static readonly SVNErrorCode CL_NO_EXTERNAL_EDITOR =
            new SVNErrorCode(CL_CATEGORY, 7, "No external editor available");

        public static readonly SVNErrorCode CL_BAD_LOG_MESSAGE =
            new SVNErrorCode(CL_CATEGORY, 8, "Something is wrong with the log message's contents");

        public static readonly SVNErrorCode CL_UNNECESSARY_LOG_MESSAGE =
            new SVNErrorCode(CL_CATEGORY, 9, "A log message was given where none was necessary");
#pragma warning restore 1591
    }
}